﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <link href="layui/css/layui.css" rel="stylesheet" />
</head>
<body>
  

        <div>
            <button type="button" class="layui-btn" id="test1">
                <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
        </div>
        <script src="layui/layui.js"></script>
        <script src="Scripts/jquery-3.7.0.min.js"></script>
       
        <script>
        layui.use('upload', function () {
            var upload = layui.upload;

            //执行实例
            var uploadInst = upload.render({
                elem: '#test1' //绑定元素
                , url: 'http://localhost:14908/api/Files' //上传接口
                , done: function (res) {
                    //上传完毕回调
                    console.log('res: ', res);
                    if (res.code== 1) {
                        alert("成功")
                    } else {
                        alert("失败")
                    }
                }
                , error: function (err) {

                    //请求异常回调
                    console.log('err: ', err);
                }
            });
        });
        </script>

    

</body>
</html>